package fr.cephb.berkeley.baseapi.bindings;

import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

/**
 * parametrized TupleBinding binding
 * because up to berkeleyDB 4.7 , there is no generic in the
 * orginal TupleBinding. This class should be deleted when the
 * version of berkeleyDB will be upgraded.
 *
 * @param <T>
 */
public abstract class TupleBinding<T>
	{
	@SuppressWarnings("unchecked")
	private com.sleepycat.bind.tuple.TupleBinding delegate=new com.sleepycat.bind.tuple.TupleBinding()
		{

		@Override
		public Object entryToObject(TupleInput input)
			{
			return TupleBinding.this.entryToObject(input);
			}
		@Override
		public void objectToEntry(Object arg0, TupleOutput arg1)
			{
			TupleBinding.this.objectToEntry((T)arg0,arg1);
			}
		};
	

	public TupleBinding()
		{
		}
	
	@SuppressWarnings("unchecked")
	public T entryToObject(com.sleepycat.db.DatabaseEntry entry)
		{
		return (T)delegate.entryToObject(entry);
		};
		
	@SuppressWarnings("unchecked")
	public void objectToEntry(T arg0, com.sleepycat.db.DatabaseEntry entry)
		{
		delegate.objectToEntry(arg0,entry);
		};
		
	
	public abstract T entryToObject(TupleInput input);
	public abstract void objectToEntry(T i, TupleOutput output);
	
	public boolean equals(Object obj)
		{
		return delegate.equals(obj);
		}
	public int getTupleBufferSize()
		{
		return delegate.getTupleBufferSize();
		}
	public int hashCode()
		{
		return delegate.hashCode();
		}
	
	public void setTupleBufferSize(int size)
		{
		delegate.setTupleBufferSize(size);
		}
	public String toString()
		{
		return delegate.toString();
		}
	
	}
